<template>
	<div class="addbanner">
		<el-row justify="space-between" style="margin-top: 2rem;">
			<el-col><h1>添加轮播广告图</h1></el-col>
		</el-row>
		
		<el-form ref="from">
			<el-row class="from-item">
				<label>描述：</label>
				<el-input style="width: 80%;" v-model.lazy.trim="memo"></el-input>
			</el-row>
			<el-row class="from-item">
				<label>热度：</label>
				<el-input style="width: 80%;" v-model.lazy.trim="hot"></el-input>
			</el-row>
			<el-row class="from-item">
				<label>类型：</label>
				<el-input style="width: 80%;" v-model.lazy.trim="type"></el-input>
			</el-row>
			<el-row>
				<label>图片：</label>
				<input type="file" ref="pic"/>
			</el-row>
		</el-form>
		<el-row justify="space-between" style="margin-top: 30px;">
		<el-col :span="5"><el-button @click="$router.push({name:'banner'})">返回</el-button></el-col>
		<el-col :span="5"><el-button type="primary" @click="putdata()">提交</el-button></el-col>
		</el-row>
	</div>
</template>

<script>
export default{
	name:'AddBanner',
	data(){
		return {
			memo:'',
			hot:'',
			type:'',
			picture:''
		}
	},
	methods:{
		putdata(){
			let pic = this.$refs.pic.files[0];
			if(pic != '' && this.memo != '' && this.hot != '' && this.type != ''){
				let params = new FormData();
				params.append('pic',pic,pic.name);
				params.append('memo',this.memo);
				params.append('id',0);
				params.append('hot',this.hot);
				params.append('type',this.type);
				this.axios.post('/api/adm/hot/addHot',params).then((res)=>{
					if(res.data.code === 200){
						this.$router.push('/admin/banner');
					}else{
						alert(res.data.msg);
					}
				}).catch((err)=>{
					//console.log(err);
				});
			}
			
		}
	}
}
</script>

<style scoped>
.addbanner{
	width: 95%;
	margin: 0 auto;
}
.addbanner .from-item label{
	line-height: 30px;
	width: 80px
}

.addbanner .el-form .from-item{
	margin: 15px 0;
}
</style>
